package com.joven.product.api.infrastructure.converter;

import com.joven.infra.common.model.PageResult;
import com.joven.product.api.business.client.model.*;
import com.joven.product.service.client.dto.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;

/**
 * 转换器
 *
 * @author Joven
 * @date 2022-01-06 18:21:27
 */
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ProductConverter {
    ProductConverter INSTANCE = Mappers.getMapper(ProductConverter.class);

    ProductCreateDTO convert(ProductCreateCmd cmd);

    ProductEditDTO convert(ProductEditCmd cmd);

    ProductPageQueryDTO convert(ProductPageQuery query);

    Product convert(ProductDTO dto);

    ProductDetail convert(ProductDetailDTO dto);

    @Mapping(source = "records", target = "records", ignore = true)
    PageResult copy(PageResult page);

    ProductCreateCmd convert(com.joven.product.api.business.service.dto.ProductCreateDTO dto);

    ProductEditCmd convert(com.joven.product.api.business.service.dto.ProductEditDTO dto);

    ProductPageQuery convert(com.joven.product.api.business.service.dto.ProductPageQueryDTO dto);

    com.joven.product.api.business.service.dto.ProductDTO convert(Product dto);

    com.joven.product.api.business.service.dto.ProductDetailDTO convert(ProductDetail detail);
}
